Step 3 of 4: Adding Code to the Application
In This Topic
In the previous steps you set up the application's user interface and added controls to your application. In this step you'll add code to your application to add additional functionality.
Complete the following steps:
- Select View | Code to switch to Code view.
- In Code view, add the following import statement to the top of the page:
Visual Basic |
Copy Code
|
Imports C1.Xaml
|
C# |
Copy Code
|
using C1.Xaml;
|
- Add the following C1MaskedTextBox_TextChanged event handlers to the project:
Visual Basic |
Copy Code
|
Private Sub c1mtb1_TextChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.TextChangedEventArgs) Handles c1mtb1.TextChanged
Me.tb2.Text = "Mask: " & Me.c1mtb1.Mask & " Value: " & Me.c1mtb1.Value & " Text: " & Me.c1mtb1.Text
End Sub
Private Sub c1mtb2_TextChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.TextChangedEventArgs) Handles c1mtb2.TextChanged
Me.tb3.Text = "Mask: " & Me.c1mtb2.Mask & " Value: " & Me.c1mtb2.Value & " Text: " & Me.c1mtb2.Text
End Sub
Private Sub c1mtb3_TextChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.TextChangedEventArgs) Handles c1mtb3.TextChanged
Me.tb4.Text = "Mask: " & Me.c1mtb3.Mask & " Value: " & Me.c1mtb3.Value & " Text: " & Me.c1mtb3.Text
End Sub
Private Sub c1mtb4_TextChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.TextChangedEventArgs) Handles c1mtb4.TextChanged
Me.tb5.Text = "Mask: " & Me.c1mtb4.Mask & " Value: " & Me.c1mtb4.Value & " Text: " & Me.c1mtb4.Text
End Sub
|
C# |
Copy Code
|
private void c1mtb1_TextChanged(object sender, TextChangedEventArgs e)
{
this.tb2.Text = "Mask: " + this.c1mtb1.Mask + " Value: " + this.c1mtb1.Value + " Text: " + this.c1mtb1.Text;
}
private void c1mtb2_TextChanged(object sender, TextChangedEventArgs e)
{
this.tb3.Text = "Mask: " + this.c1mtb2.Mask + " Value: " + this.c1mtb2.Value + " Text: " + this.c1mtb2.Text;
}
private void c1mtb3_TextChanged(object sender, TextChangedEventArgs e)
{
this.tb4.Text = "Mask: " + this.c1mtb3.Mask + " Value: " + this.c1mtb3.Value + " Text: " + this.c1mtb3.Text;
}
private void c1mtb4_TextChanged(object sender, TextChangedEventArgs e)
{
this.tb5.Text = "Mask: " + this.c1mtb4.Mask + " Value: " + this.c1mtb4.Value + " Text: " + this.c1mtb4.Text;
}
|
- Add code to the page's constructor so that it appears like the following:
Visual Basic |
Copy Code
|
Public Sub New()
InitializeComponent()
Me.c1mtb1_TextChanged(Nothing, Nothing)
Me.c1mtb2_TextChanged(Nothing, Nothing)
Me.c1mtb3_TextChanged(Nothing, Nothing)
Me.c1mtb4_TextChanged(Nothing, Nothing)
End Sub
|
C# |
Copy Code
|
public MainPage()
{
InitializeComponent();
this.c1mtb1_TextChanged(null, null);
this.c1mtb2_TextChanged(null, null);
this.c1mtb3_TextChanged(null, null);
this.c1mtb4_TextChanged(null, null);
}
|
In this step you completed adding code to your application. In the next step you'll run the application and observe run-time interactions.
See Also